

#include "core/components_ng/pattern/mycircle/mycircle_paint_method.h"

#include "base/geometry/dimension.h"
#include "core/components_ng/render/drawing.h"
#include "core/components_ng/render/drawing_prop_convertor.h"

namespace OHOS::Ace::NG {

CanvasDrawFunction MyCirclePaintMethod::GetContentDrawFunction(PaintWrapper* paintWrapper)
{
    auto offset = paintWrapper->GetContentOffset();
    auto mycirclePaintProperty = DynamicCast<MyCirclePaintProperty>(paintWrapper->GetPaintProperty());
    CHECK_NULL_RETURN(mycirclePaintProperty, nullptr);
    Color edgeColor = mycirclePaintProperty->GetEdgeColor().value_or(Color::BLACK);

    return [radius = radius_, edgeColor, edgeWidth = edgeWidth_, offset](RSCanvas& canvas) {
        canvas.Save();
        RSPen pen;
        pen.SetAntiAlias(true);
        pen.SetColor(ToRSColor(edgeColor));
        pen.SetWidth(edgeWidth);
        canvas.AttachPen(pen);
        auto centerPt = RSPoint(offset.GetX() + radius, offset.GetY() + radius);
        canvas.DrawCircle(centerPt, radius);
        canvas.DetachPen();
        canvas.Restore();
    };
}
} // namespace OHOS::Ace::NG
